package main

//register to Ls
//forward message to corresponding server

import (
	"GtEngine"
	"fmt"
	"strconv"
	. "tksConfig"
	. "tksLog"
	. "tksStatic"
)

func registerServerCmd() {
	GtEngine.RegisterGateCmd(CmdServerConnectGateReq, GtEngine.ServerConnect)
	GtEngine.RegisterGateCmd(CmdGateHeartbeatReq, GtEngine.ServerHeartbeat)
	//
	GtEngine.RegisterGateCmd(CmdClientConnectGateReq, GtEngine.ClientConnect)
}

func main() {
	InitLogger("gate")
	//
	LoadConfig("config.json")
	i, _ := Config.Get("server").Get("id").Int()
	GtEngine.GateId = uint32(i)
	port, _ := Config.Get("server").Get("port").Int()
	//
	registerServerCmd()
	err := GtEngine.NewGate(":" + strconv.Itoa(port))
	if err != nil {
		fmt.Println(err)
	}
}
